import requests
from scrapy_plus.http.response import Response


class Downloader:
    def get_response(self, request):
        if request.method == "GET":
            resp =  requests.get(request.url, headers=request.headers, params=request.params)
        elif request.method == "POST":
            resp = requests.post(request.ur, headers=request.headers, params=request.params)
        else:
            raise Exception("不支持的请求方法")
            
        return Response(resp.url, resp.status_code, resp.headers, resp.content)
